import { GET_AVATAR, GET_COOKIE, GET_USERID, HIDDEN_LOADING, SHOW_LOADING } from './mutations-type'

export default {
  // 存储获取用户ID
  [GET_USERID](state) {
    state.userId = localStorage.getItem('uid')
  },

  // 显示加载
  [SHOW_LOADING](state) {
    state.isLoading = true
  },

  // 取消加载
  [HIDDEN_LOADING](state) {
    state.isLoading = false
  },

  // 保存用户头像
  [GET_AVATAR](state) {
    if (localStorage.getItem('avatar')) {
      state.avatarUrl = localStorage.getItem('avatar')
    }
    return state.avatarUrl
  },

  // 保存cookie值
  [GET_COOKIE](state) {
    if (localStorage.getItem('cookie')) {
      state.cookie = localStorage.getItem('cookie')
    }
    return state.cookie
  }
}
